<template>
	<div>
		
		<Row style="text-align: left;margin-top: 41px;">
			<Col span="12" style="text-align: left;">
			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">课程设置</span>
			</Col>
		</Row>
		<Row style="padding:35px 40px 0px 45px;width: 100%;">
			<Col span="24" style="text-align: left;display: inline-block;">
			<span style="margin: 0 10px ;">年&nbsp;&nbsp;&nbsp;&nbsp;级：</span>
			<Select v-model="grade" @on-change="gradeChange" style="width: 150px;text-align: center;">
				<Option v-for="item in gradeList" :value="item.value" :key="item.value">{{item.label}}</Option>
			</Select>

			<Button style="float: right;background-color: orange;color: white;font-size: 14px;margin: 0 45px;" @click="addteachergroup">+&nbsp;添加课程</Button>
			</Col>
		</Row>
		<div style="min-height: 300px; padding-bottom:20px ;">
			<Row style="margin:0 auto;margin:20px 45px 5px 45px;color: #666666;border-radius: 10px; background-color: #f0f8ff;padding: 10px 0;">
				<Col span="3" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">序号</span>
				</Col>
				<Col span="4" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">学科</span>
				</Col>
				<Col span="3" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">是否选修</span>
				</Col>
				<Col span="3" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">是否选课程</span>
				</Col>
				<Col span="3" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">是否选考课程</span>
				</Col>
				<Col span="3" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">操作</span>
				</Col>
			</Row>
			<Row v-for="(item,index) in manageList" :key="item.itemId" style="margin:0 auto;margin:20px 45px 5px 45px;">
				<Col span="3" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">{{item.itemId}}&nbsp;</span>
				</Col>
				<Col span="4" style="text-align: center;width: 16%;">
				<span style="font-size: 16px;">{{item.subject}}&nbsp;</span>
				</Col>
				<Col span="3" style="text-align: center;width: 16%;">
				<i-switch  size="small" v-model="item.switch1" @on-change="change1" style="color: green;"/>
				</Col>
				<Col span="3" style="text-align: center;width: 16%;">
				<i-switch  size="small" v-model=" item.switch2" @on-change="change2" style="color: green;"/>
				</Col>
				<Col span="3" style="text-align: center;width: 16%;">
				<i-switch  size="small" v-model="item.switch3" @on-change="change3" style="color: green;"/>
				</Col>

				<Col span="4" style="text-align: center;width: 16%;">
				<a style="font-size: 16px;color: blue;" @click="xkpkdel(index)">删除&nbsp;</a>
				</Col>
			</Row>
		</div>
		<div v-if="sortSettingHidden" span="10" style=" width: 600px; z-index: 1000;background-color: white;margin:0 auto;position: absolute;top: 200px;left: 0;right: 0;text-align: left;height:550px;border: 1px solid #e9eaec;padding: 50px;border-radius: 15px;">
			<Row style="width: 100%;text-align: center;margin-bottom: 20px;">
				<span style="margin-bottom: 20px;font-size: 21px;">{{title}}</span>
			</Row>
			<Row style="font-size: 15px;">
				<Col style="text-align: center;padding: 10px;">
				<span>学&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;科:</span>
				<Select v-model="subjectname" @on-change="subjectnameChange" style="text-align: center; width: 60%;position: relative;">
					<Option v-for="(item,index) in subjectnameList" :value="item.label" :key="item.label">{{item.label}}</Option>
				</Select>
				</Col>
				<Row style="width: 100%;text-align: center;padding: 10px;">
				<Col span="3" style="text-align: center;width: 33.3%;">
					<span style="font-size: 16px;">是否选课程</span>
				<i-switch  size="small" v-model="xuanxiu" @on-change="xuanxiuchange" style="color: green;"/>
				</Col>
				<Col span="3" style="text-align: center;width: 33.3%;">
					<span style="font-size: 16px;">是否选课程</span>
				<i-switch  size="small" v-model="xuankecheng" @on-change="xuankechengchange" style="color: green;"/>
				</Col>
				<Col span="3" style="text-align: center;width: 33.3%;">
					<span style="font-size: 16px;">是否选考课程</span>
				<i-switch  size="small" v-model="xuankaokecheng" @on-change="xuankaokechengchange" style="color: green;"/>
				</Col>
				</Row>
			</Row>
			<Row style="text-align: center;">
				<Col span="24" style="margin-top:15px">
				<Button type="ghost" @click="cancel" icon="close-round" style="margin-right: 20px;">取消</Button>
				<Button v-if="this.title=='添加课程'?true:false" type="primary" @click="savesort" icon="checkmark-round">保存</Button>
				<Button v-if="this.title=='编辑课程'?true:false" type="primary" @click="editsavesort" icon="checkmark-round">保存</Button>
				</Col>
			</Row>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				obj:"",
				listitemId:"",
				title:"",
				xuanxiu:false,
				xuankecheng:false,
				xuankaokecheng:false,
				subjectname:"语文",
				
				sortSettingHidden:false,
				grade: 1,
				subjectnameList:[
				{
					value:1,
					label:"语文",
				},
				{
					value:2,
					label:"数学",
				},
				{
					value:3,
					label:"英语",
				},
				{
					value:4,
					label:"政治",
				},
				{
					value:5,
					label:"历史",
				},
				{
					value:6,
					label:"地理",
				},
				{
					value:7,
					label:"物理",
				},
				{
					value:8,
					label:"化学",
				},
				{
					value:9,
					label:"生物",
				},
				],
				gradeList: [{
						value: 1,
						label: "高一",
					},
					{
						value: 2,
						label: "高二",
					},
					{
						value: 3,
						label: "高三",
					},
					{
						value: 4,
						label: "初一",
					},
					{
						value: 5,
						label: "初二",
					},
					{
						value: 6,
						label: "初三",
					},

				],
				manageList: [{
						itemId: "01",
						subject: "语文",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "02",
						subject: "数学",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "03",
						subject: "英语",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "04",
						subject: "政治",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "05",
						subject: "历史",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "06",
						subject: "地理",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "07",
						subject: "物理",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "08",
						subject: "化学",
						switch1: true,
						switch2: false,
						switch3: true,
					},
					{
						itemId: "09",
						subject: "生物",
						switch1: true,
						switch2: false,
						switch3: true,
					},
				],
			}
		},
		methods: {
			gradeChange: function() {},
			addteachergroup: function() {
				this.title="添加课程"
				this.sortSettingHidden=true
				this.xuanxiu=false
				this.xuankecheng=false
				this.xuankaokecheng=false
				this.gradename="语文"
			},
			xkpkedit: function() {
				this.title="编辑课程"
				this.sortSettingHidden=true
				this.xuanxiu=this.manageList[index].switch1
				this.xuankecheng=this.manageList[index].switch2
				this.xuankaokecheng=this.manageList[index].switch3
				this.gradename=this.manageList[index].subject
				this.obj=index
				this.listitemId=this.manageList[index].itemId
			},
			xkpkdel: function(index) {
				this.manageList.splice(index, 1)
			},
			change1:function(){},
			change2: function() {},
			change3: function() {},
			savesort:function(){
				this.sortSettingHidden=false
				this.manageList.push({
					itemId:"0"+(this.manageList.length+1),
					subject:this.subjectname,
					switch1: this.xuanxiu,
					switch2: this.xuankecheng,
					switch3: this.xuankaokecheng,
				})
				alert('保存成功')
			},
			cancel:function(){
				this.sortSettingHidden=false
			},
			subjectnameChange:function(){},
			xuanxiuchange:function(){},
			xuankechengchange:function(){},
			xuankaokechengchange:function(){},
			editsavesort:function(){
				this.sortSettingHidden=false
				this.manageList.splice(this.obj, 1, {
					itemId:this.listitemId,
					subject:this.subjectname,
					switch1: this.xuanxiu,
					switch2: this.xuankecheng,
					switch3: this.xuankaokecheng,
				})
				alert('保存成功')
			},
		},
	}
</script>

<style>

</style>